# 1. 导包
from time import sleep
from selenium import webdriver

# 2. 创建浏览器对象, 并打开指定网页
driver = webdriver.Chrome()
driver.maximize_window()
driver.get("http://www.baidu.com")

# 2.1 添加和登录相关的cookie
cookies = [
    {"name": "BDUSS",
     "value": "XVadnBmdjVZUkt0eTJSVnExUUZnMmVjclE5VTBkZk9yOHA0U1JUb3FifmpDanBrSVFBQUFBJCQAAAAAAQAAAAEAAAD6VtNn19Oyu9PvX1JKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAON9EmTjfRJkc"},
    {"name": "BDUSS_BFESS",
     "value": "XVadnBmdjVZUkt0eTJSVnExUUZnMmVjclE5VTBkZk9yOHA0U1JUb3FifmpDanBrSVFBQUFBJCQAAAAAAQAAAAEAAAD6VtNn19Oyu9PvX1JKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAON9EmTjfRJkc"}
]
for cookie in cookies:
    driver.add_cookie(cookies)

# 2.2 刷新网页
driver.refresh()

# 3. 关闭浏览器
sleep(10)
driver.quit()
